package com.tiantang.study.netty.reactor;

/**
 * @author liujinkun
 * @Title: AcceptEventHandler
 * @Description: ACCEPT事件处理器
 * @date 2019/5/5 7:34 PM
 */
public class AcceptEventHandler extends EventHandler{

    private Selector selector;

    public AcceptEventHandler (Selector selector){
        this.selector = selector;
    }

    public void handle(Event event) {
        // 处理Accept事件
        if(event.getEventType() == EventType.ACCEPT){
            // TODO 处理Accept时间的状态

            // 将事件改为下一个READ状态，并放入Selector的缓冲队列中
            Event readEvent = new Event();
            readEvent.setEventType(EventType.READ);
            readEvent.setInputSource(event.getInputSource());
            selector.addEvent(readEvent);
        }

    }
}
